#ifndef UNREALBOT_H
#define UNREALBOT_H

#include "unrealmap.h"
#include "logviewer.h"


struct UnrealNativeBot: public MapObject{
	UnrealNativeBot(RouteMap* map, string nm="", string id="", int team=0, Place* place=0, string weapon=""):MapObject(map, place, nm),id(id), team(team), weapon(weapon){
	
	}
    string id;
    int team;
    string weapon;
};


class UnrealHandler;

class UnrealBot : public Bot, public UnrealNativeBot{

	
protected:
RefPtr<SocketClient> socketSource;
RefPtr<SocketConnection> connection;


friend class UnrealHandler;


protected:
    logViewer logger;
    UnrealStream* botstream;
	ustring adres;
	unsigned port;
	// the output we send to the bot;
public:
    Mutex mutex;
    UnrealHandler* handler;

	UnrealBot(RefPtr<SocketClient>& sockSource, ustring addr, unsigned port );

    void log(ustring msg, bool bold=false){
        logger.log(msg, bold);
    }

    virtual bool connect(){
		return connect(adres, port);
	}
	
    virtual bool connect(ustring addr, unsigned prt);
    /*
    virtual bool run(){
        switch(state){
        case paused:
        case initialized:
            state=running;
            return true;
        case none:
        case connection_error:
            if(!connect()) return false;//quit if connect doesn't work, otherwise continui with connected part
        case connected:
        case running:

            processInput();
        }
        return true;
    }*/
    virtual void processInput();
    private://sub-pecedures of processinput;
        void handleNFO();
        /**
        handles the NFO command after the NFO itself has been read from the inputstream.
        it saves all the info in the gameinfos struct.
        */
        void handleSMUT();
        /** handles the SMUT command
            for now it just reads until the EMUT message
            because we don't really care for mutators.
        */
    virtual bool round();


};



#endif
